/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EDataTypeEList;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

import org.xtext.example.cr.cR.Array;
import org.xtext.example.cr.cR.ArrayElement;
import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.Delete;
import org.xtext.example.cr.cR.FindSimilar;
import org.xtext.example.cr.cR.HighestCR;
import org.xtext.example.cr.cR.Index;
import org.xtext.example.cr.cR.SimpleVariable;
import org.xtext.example.cr.cR.Size;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Delete</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.DeleteImpl#getArray <em>Array</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.DeleteImpl#getArrayElement <em>Array Element</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.DeleteImpl#getMethod <em>Method</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.DeleteImpl#getDelElements <em>Del Elements</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.DeleteImpl#getDelVars <em>Del Vars</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.DeleteImpl#getDelArrays <em>Del Arrays</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.DeleteImpl#getSize <em>Size</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.DeleteImpl#getIndexs <em>Indexs</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.DeleteImpl#getFindSimilars <em>Find Similars</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.DeleteImpl#getHighestCRs <em>Highest CRs</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.DeleteImpl#getIndxs <em>Indxs</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DeleteImpl extends MinimalEObjectImpl.Container implements Delete
{
  /**
   * The cached value of the '{@link #getArray() <em>Array</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArray()
   * @generated
   * @ordered
   */
  protected Array array;

  /**
   * The cached value of the '{@link #getArrayElement() <em>Array Element</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getArrayElement()
   * @generated
   * @ordered
   */
  protected ArrayElement arrayElement;

  /**
   * The default value of the '{@link #getMethod() <em>Method</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMethod()
   * @generated
   * @ordered
   */
  protected static final String METHOD_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getMethod() <em>Method</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getMethod()
   * @generated
   * @ordered
   */
  protected String method = METHOD_EDEFAULT;

  /**
   * The cached value of the '{@link #getDelElements() <em>Del Elements</em>}' attribute list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDelElements()
   * @generated
   * @ordered
   */
  protected EList<Integer> delElements;

  /**
   * The cached value of the '{@link #getDelVars() <em>Del Vars</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDelVars()
   * @generated
   * @ordered
   */
  protected EList<SimpleVariable> delVars;

  /**
   * The cached value of the '{@link #getDelArrays() <em>Del Arrays</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDelArrays()
   * @generated
   * @ordered
   */
  protected EList<ArrayElement> delArrays;

  /**
   * The cached value of the '{@link #getSize() <em>Size</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getSize()
   * @generated
   * @ordered
   */
  protected EList<Size> size;

  /**
   * The cached value of the '{@link #getIndexs() <em>Indexs</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getIndexs()
   * @generated
   * @ordered
   */
  protected EList<Index> indexs;

  /**
   * The cached value of the '{@link #getFindSimilars() <em>Find Similars</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFindSimilars()
   * @generated
   * @ordered
   */
  protected EList<FindSimilar> findSimilars;

  /**
   * The cached value of the '{@link #getHighestCRs() <em>Highest CRs</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getHighestCRs()
   * @generated
   * @ordered
   */
  protected EList<HighestCR> highestCRs;

  /**
   * The cached value of the '{@link #getIndxs() <em>Indxs</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getIndxs()
   * @generated
   * @ordered
   */
  protected EList<Index> indxs;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected DeleteImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.DELETE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Array getArray()
  {
    if (array != null && array.eIsProxy())
    {
      InternalEObject oldArray = (InternalEObject)array;
      array = (Array)eResolveProxy(oldArray);
      if (array != oldArray)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, CRPackage.DELETE__ARRAY, oldArray, array));
      }
    }
    return array;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Array basicGetArray()
  {
    return array;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setArray(Array newArray)
  {
    Array oldArray = array;
    array = newArray;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.DELETE__ARRAY, oldArray, array));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ArrayElement getArrayElement()
  {
    return arrayElement;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetArrayElement(ArrayElement newArrayElement, NotificationChain msgs)
  {
    ArrayElement oldArrayElement = arrayElement;
    arrayElement = newArrayElement;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.DELETE__ARRAY_ELEMENT, oldArrayElement, newArrayElement);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setArrayElement(ArrayElement newArrayElement)
  {
    if (newArrayElement != arrayElement)
    {
      NotificationChain msgs = null;
      if (arrayElement != null)
        msgs = ((InternalEObject)arrayElement).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.DELETE__ARRAY_ELEMENT, null, msgs);
      if (newArrayElement != null)
        msgs = ((InternalEObject)newArrayElement).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.DELETE__ARRAY_ELEMENT, null, msgs);
      msgs = basicSetArrayElement(newArrayElement, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.DELETE__ARRAY_ELEMENT, newArrayElement, newArrayElement));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getMethod()
  {
    return method;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setMethod(String newMethod)
  {
    String oldMethod = method;
    method = newMethod;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.DELETE__METHOD, oldMethod, method));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Integer> getDelElements()
  {
    if (delElements == null)
    {
      delElements = new EDataTypeEList<Integer>(Integer.class, this, CRPackage.DELETE__DEL_ELEMENTS);
    }
    return delElements;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<SimpleVariable> getDelVars()
  {
    if (delVars == null)
    {
      delVars = new EObjectResolvingEList<SimpleVariable>(SimpleVariable.class, this, CRPackage.DELETE__DEL_VARS);
    }
    return delVars;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<ArrayElement> getDelArrays()
  {
    if (delArrays == null)
    {
      delArrays = new EObjectContainmentEList<ArrayElement>(ArrayElement.class, this, CRPackage.DELETE__DEL_ARRAYS);
    }
    return delArrays;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Size> getSize()
  {
    if (size == null)
    {
      size = new EObjectContainmentEList<Size>(Size.class, this, CRPackage.DELETE__SIZE);
    }
    return size;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Index> getIndexs()
  {
    if (indexs == null)
    {
      indexs = new EObjectContainmentEList<Index>(Index.class, this, CRPackage.DELETE__INDEXS);
    }
    return indexs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<FindSimilar> getFindSimilars()
  {
    if (findSimilars == null)
    {
      findSimilars = new EObjectContainmentEList<FindSimilar>(FindSimilar.class, this, CRPackage.DELETE__FIND_SIMILARS);
    }
    return findSimilars;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<HighestCR> getHighestCRs()
  {
    if (highestCRs == null)
    {
      highestCRs = new EObjectContainmentEList<HighestCR>(HighestCR.class, this, CRPackage.DELETE__HIGHEST_CRS);
    }
    return highestCRs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Index> getIndxs()
  {
    if (indxs == null)
    {
      indxs = new EObjectContainmentEList<Index>(Index.class, this, CRPackage.DELETE__INDXS);
    }
    return indxs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.DELETE__ARRAY_ELEMENT:
        return basicSetArrayElement(null, msgs);
      case CRPackage.DELETE__DEL_ARRAYS:
        return ((InternalEList<?>)getDelArrays()).basicRemove(otherEnd, msgs);
      case CRPackage.DELETE__SIZE:
        return ((InternalEList<?>)getSize()).basicRemove(otherEnd, msgs);
      case CRPackage.DELETE__INDEXS:
        return ((InternalEList<?>)getIndexs()).basicRemove(otherEnd, msgs);
      case CRPackage.DELETE__FIND_SIMILARS:
        return ((InternalEList<?>)getFindSimilars()).basicRemove(otherEnd, msgs);
      case CRPackage.DELETE__HIGHEST_CRS:
        return ((InternalEList<?>)getHighestCRs()).basicRemove(otherEnd, msgs);
      case CRPackage.DELETE__INDXS:
        return ((InternalEList<?>)getIndxs()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.DELETE__ARRAY:
        if (resolve) return getArray();
        return basicGetArray();
      case CRPackage.DELETE__ARRAY_ELEMENT:
        return getArrayElement();
      case CRPackage.DELETE__METHOD:
        return getMethod();
      case CRPackage.DELETE__DEL_ELEMENTS:
        return getDelElements();
      case CRPackage.DELETE__DEL_VARS:
        return getDelVars();
      case CRPackage.DELETE__DEL_ARRAYS:
        return getDelArrays();
      case CRPackage.DELETE__SIZE:
        return getSize();
      case CRPackage.DELETE__INDEXS:
        return getIndexs();
      case CRPackage.DELETE__FIND_SIMILARS:
        return getFindSimilars();
      case CRPackage.DELETE__HIGHEST_CRS:
        return getHighestCRs();
      case CRPackage.DELETE__INDXS:
        return getIndxs();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.DELETE__ARRAY:
        setArray((Array)newValue);
        return;
      case CRPackage.DELETE__ARRAY_ELEMENT:
        setArrayElement((ArrayElement)newValue);
        return;
      case CRPackage.DELETE__METHOD:
        setMethod((String)newValue);
        return;
      case CRPackage.DELETE__DEL_ELEMENTS:
        getDelElements().clear();
        getDelElements().addAll((Collection<? extends Integer>)newValue);
        return;
      case CRPackage.DELETE__DEL_VARS:
        getDelVars().clear();
        getDelVars().addAll((Collection<? extends SimpleVariable>)newValue);
        return;
      case CRPackage.DELETE__DEL_ARRAYS:
        getDelArrays().clear();
        getDelArrays().addAll((Collection<? extends ArrayElement>)newValue);
        return;
      case CRPackage.DELETE__SIZE:
        getSize().clear();
        getSize().addAll((Collection<? extends Size>)newValue);
        return;
      case CRPackage.DELETE__INDEXS:
        getIndexs().clear();
        getIndexs().addAll((Collection<? extends Index>)newValue);
        return;
      case CRPackage.DELETE__FIND_SIMILARS:
        getFindSimilars().clear();
        getFindSimilars().addAll((Collection<? extends FindSimilar>)newValue);
        return;
      case CRPackage.DELETE__HIGHEST_CRS:
        getHighestCRs().clear();
        getHighestCRs().addAll((Collection<? extends HighestCR>)newValue);
        return;
      case CRPackage.DELETE__INDXS:
        getIndxs().clear();
        getIndxs().addAll((Collection<? extends Index>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.DELETE__ARRAY:
        setArray((Array)null);
        return;
      case CRPackage.DELETE__ARRAY_ELEMENT:
        setArrayElement((ArrayElement)null);
        return;
      case CRPackage.DELETE__METHOD:
        setMethod(METHOD_EDEFAULT);
        return;
      case CRPackage.DELETE__DEL_ELEMENTS:
        getDelElements().clear();
        return;
      case CRPackage.DELETE__DEL_VARS:
        getDelVars().clear();
        return;
      case CRPackage.DELETE__DEL_ARRAYS:
        getDelArrays().clear();
        return;
      case CRPackage.DELETE__SIZE:
        getSize().clear();
        return;
      case CRPackage.DELETE__INDEXS:
        getIndexs().clear();
        return;
      case CRPackage.DELETE__FIND_SIMILARS:
        getFindSimilars().clear();
        return;
      case CRPackage.DELETE__HIGHEST_CRS:
        getHighestCRs().clear();
        return;
      case CRPackage.DELETE__INDXS:
        getIndxs().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.DELETE__ARRAY:
        return array != null;
      case CRPackage.DELETE__ARRAY_ELEMENT:
        return arrayElement != null;
      case CRPackage.DELETE__METHOD:
        return METHOD_EDEFAULT == null ? method != null : !METHOD_EDEFAULT.equals(method);
      case CRPackage.DELETE__DEL_ELEMENTS:
        return delElements != null && !delElements.isEmpty();
      case CRPackage.DELETE__DEL_VARS:
        return delVars != null && !delVars.isEmpty();
      case CRPackage.DELETE__DEL_ARRAYS:
        return delArrays != null && !delArrays.isEmpty();
      case CRPackage.DELETE__SIZE:
        return size != null && !size.isEmpty();
      case CRPackage.DELETE__INDEXS:
        return indexs != null && !indexs.isEmpty();
      case CRPackage.DELETE__FIND_SIMILARS:
        return findSimilars != null && !findSimilars.isEmpty();
      case CRPackage.DELETE__HIGHEST_CRS:
        return highestCRs != null && !highestCRs.isEmpty();
      case CRPackage.DELETE__INDXS:
        return indxs != null && !indxs.isEmpty();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (method: ");
    result.append(method);
    result.append(", delElements: ");
    result.append(delElements);
    result.append(')');
    return result.toString();
  }

} //DeleteImpl
